package 剑指offer;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class p54二叉搜索树的第k大节点 {
    public int kthLargest(TreeNode root, int k) {
        List<Integer> list=new ArrayList<>();

        list=inoder(root,list);

        return list.get(list.size()-k);
    }

    private List<Integer> inoder(TreeNode root,List<Integer> list) {
        if (root==null) {
            return null;
        }

        inoder(root.left,list);
        list.add(root.val);
        inoder(root.right,list);

        return list;
    }

}
